package com.railway.switchs.action.business;

import com.railway.switchs.domain.query.business.SwitchInfoQuery;
import com.railway.switchs.enums.EnumRunType;
import com.railway.switchs.service.business.ISwitchInfoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

/**
 * @ClassName StatisticsAction
 * @Author 魏梓晟
 * @Version 1.0
 **/
@Controller
@Slf4j
@RequestMapping("/back/statistics")
public class StatisticsAction {

    @Autowired
    private ISwitchInfoService switchInfoService;

    /**
     * 进入基础设备页面
     * @return
     */
    @RequestMapping(value = "/list",method = RequestMethod.GET)
    public ModelAndView list(){
        ModelAndView mav = new ModelAndView();
        //未使用的道岔
        SwitchInfoQuery switchInfoQuery= new SwitchInfoQuery();
        switchInfoQuery.setRunType(EnumRunType.UNUSED.getCode());
        mav.addObject("unUsedSwitch",switchInfoService.getList(switchInfoQuery).size());
        //维修中的道岔
        switchInfoQuery.setRunType(EnumRunType.MAINTENANCE.getCode());
        mav.addObject("maintenanceSwitch",switchInfoService.getList(switchInfoQuery).size());
        //正常使用中的道岔
        switchInfoQuery.setRunType(EnumRunType.USED.getCode());
        mav.addObject("usedSwitch",switchInfoService.getList(switchInfoQuery).size());
        mav.setViewName("statistics/list");
        return mav;
    }
}
